package docker

//docker命令
//帮助文档的地址  https://docs.docker.com/engine/reference/run/


/*

-------帮助命令----------

	docker version  //显示docker的版本信息
	docker info  //显示docker的系统信息，包括显示镜像和容器的数量
	docker [命令] --help //帮助命令
		as: docker images --help



-------查看日志----------

	docker logs	[可选项] 容器id
		docker logs --help
		Options:
				--details        Show extra details provided to logs
			-f, --follow         Follow log output
				--since string   Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42minutes)
			-n, --tail string    Number of lines to show from the end of the logs (default "all")
			-t, --timestamps     Show timestamps
				--until string   Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for42 minutes)

		docker logs -tf --tail 10 c7ed261c1b59  显示指定的条数记录

			--tail num 以字符的形式显示 ,num 显示多少条
			-tf 显示全部日志


-------查看容器中的进程信息----------

	docker top 容器id

[root@VM_0_13_centos ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
e6d3268bb0bc   nginx     "/docker-entrypoint.…"   23 minutes ago   Up 23 minutes   80/tcp    laughing_blackburn
[root@VM_0_13_centos ~]# docker top e6d3268bb0bc
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                20171               20150               0                   09:02               ?                   00:00:00            nginx: master process nginx -g daemon off;
101                 20223               20171               0                   09:02               ?                   00:00:00            nginx: worker process
101                 20224               20171               0                   09:02               ?                   00:00:00            nginx: worker process
[root@VM_0_13_centos ~]#

UID 当前用户id
PID 父id
PPID 进程id




-------查看镜像的元数据/配置信息----------

	docker inspect 容器id
			--help

	//查看版本信息
	//docker image inspect nginx:latest | grep -i version
	docker  inspect nginx | grep -i version



[root@VM_0_13_centos ~]# docker inspect --help

Usage:  docker inspect [OPTIONS] NAME|ID [NAME|ID...]

Return low-level information on Docker objects

Options:
  -f, --format string   Format the output using the given Go template
  -s, --size            Display total file sizes if the type is container
      --type string     Return JSON for specified type
[root@VM_0_13_centos ~]#


[root@VM_0_13_centos ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
e6d3268bb0bc   nginx     "/docker-entrypoint.…"   23 minutes ago   Up 23 minutes   80/tcp    laughing_blackburn
[root@VM_0_13_centos ~]#
[root@VM_0_13_centos ~]# docker inspect e6d3268bb0bc
[
    {
		#容器的id
        "Id": "e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816",
        "Created": "2022-09-05T01:02:55.294672763Z",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 20171,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-09-05T01:02:55.735177696Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85",
        "ResolvConfPath": "/var/lib/docker/containers/e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816/hostname",
        "HostsPath": "/var/lib/docker/containers/e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816/hosts",
        "LogPath": "/var/lib/docker/containers/e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816/e6d3268bb0bc2c9c04d4fc78114ca3a426f4ddab13a8a0718bd2af31fc272816-json.log",
        "Name": "/laughing_blackburn",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/1977dc9bb08aa51275af4adf0de49ba5166bd7ff7f6ff17c1e37244314045f7b-init/diff:/var/lib/docker/overlay2/1c40476fe9e5667a5cbaa0e23ac3451d20173c532867dfee35f8ef1586c7ffa3/diff:/var/lib/docker/overlay2/86b749c90844d30c85a938fe22f04a7c15d35a5678863a0b41b943555da24ea7/diff:/var/lib/docker/overlay2/b6f01ca75e7b563410d499e51cef5eee3728dc508f5f29520c3774829757a0e7/diff:/var/lib/docker/overlay2/82e227f82c7f6644544b9c24f4ed853b8bcfd5c2f0eeef175162525b3d494afc/diff:/var/lib/docker/overlay2/e8b6667ec2847eeff0e327ddf10ffd04f8b841c6b454150354ff3e03d08064bb/diff:/var/lib/docker/overlay2/442511b8cd116dba886dab9de5ab0bff4542065f511e113ec1adc8ea38ec2f47/diff",
                "MergedDir": "/var/lib/docker/overlay2/1977dc9bb08aa51275af4adf0de49ba5166bd7ff7f6ff17c1e37244314045f7b/merged",
                "UpperDir": "/var/lib/docker/overlay2/1977dc9bb08aa51275af4adf0de49ba5166bd7ff7f6ff17c1e37244314045f7b/diff",
                "WorkDir": "/var/lib/docker/overlay2/1977dc9bb08aa51275af4adf0de49ba5166bd7ff7f6ff17c1e37244314045f7b/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "e6d3268bb0bc",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.21.5",
                "NJS_VERSION=0.7.1",
                "PKG_RELEASE=1~bullseye"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "Image": "nginx",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "582bd95cc2b51be06a865aa8ca338c623824f95f11268ba6812a42bf755521ac",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/582bd95cc2b5",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "4e91c55db2ff2012c303333ffe56d30e5490acc60a84a41c19fa83194ee9d182",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "33fa0f5c60ac7e7c69a1f0ff8eaf0b31c2b7f4b3fd313b5fc0c70f62faca984d",
                    "EndpointID": "4e91c55db2ff2012c303333ffe56d30e5490acc60a84a41c19fa83194ee9d182",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]
[root@VM_0_13_centos ~]#





*/
